package com.pdg.mcplugin.ranger.api;

import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.plugin.RegisteredServiceProvider;

public class RangerAPIAdapter {
	private static final String RANGER = "Ranger";
	private static RangerAPI api = null;
	private static boolean loaded = false;
	public static RangerAPI getRangerAPI(){
		if(!loaded){
			loaded = true;
			Server theServer = Bukkit.getServer();
			if(theServer.getPluginManager().getPlugin(RANGER)!=null){
				RegisteredServiceProvider<RangerAPI> rsp = theServer.getServicesManager().getRegistration(RangerAPI.class);
				if(rsp!=null){
					api = rsp.getProvider();
				}
			}
		}
		return api;
	}
}
